import java.util.Scanner;

public class HJ2 {
    public static void main(String[] args) {//计算某字符出现次数
        Scanner in = new Scanner(System.in);
        String Str = in.nextLine();
        String temple = in.nextLine();
        char targetChar = temple.charAt(0); // 获取目标字符
        int count = 0;
        if (Character.isLetter(targetChar)) {
            // 统计大小写形态的出现次数
            char lowerCaseChar = Character.toLowerCase(targetChar);
            char upperCaseChar = Character.toUpperCase(targetChar);

            for (int i = 0; i < Str.length(); i++) {
                if (Str.charAt(i) == lowerCaseChar || Str.charAt(i) == upperCaseChar) {
                    count++;
                }
            }
        } else {
            // 如果不是字母，只统计目标字符本身
            for (int i = 0; i < Str.length(); i++) {
                if (Str.charAt(i) == targetChar) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}
